<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var reg = /(0[0-9]{2,3}-){0,1}[0-9]{7,8}/g;
    var s = '23442344';//021 23442344
    var r = s.match(reg);
    console.log(r);
</script>
</body>
</html>